// pages/myOrder/index.js
//引入请求文件
var util = require('../../utils/util.js');
var WXBizDataCrypt = require('../../crypto/WXBizDataCrypt.js');
let app = getApp();
let url = app.url;
let gobalData = app.gobalData;
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		cid: 0,
		teamList: [],
		superviseList: [],
		imgFlag: false
	},
	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function(options) {
		this.setData({
			cid: options.cid
		})
		util(`${url}User/getUserOrder`, {
			cid: this.data.cid
		}).then(res => {
			if (res.status == 1) {
				this.setData({
					teamList: res.content.groupList,
					superviseList: res.content.supervisionList.reverse()
				})
			} else {
				if ( this.data.superviseList.length == 0 && this.data.teamList) {
					this.setData({
						imgFlag : true
					})
				}
				throw res.msg;
			}
		})

	},
	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage: function(e) {
		let id = e.target.dataset.id;
		let picture = e.target.dataset.picture;
		let groupactivityid = e.target.dataset.groupactivityid;
		return {
			title: '我正在装笆参加免费验房活动，快来和我一起吧！',
			imageUrl: picture,
			path: '/pages/team/index?groupFoundId=' + id + '&groupActivityId=' + groupactivityid + '&isTema=' + 1 + '&leaderId=' + wx.getStorageSync('userInfo').userInfo.id
		}
	}
})
